package com.azhon.entry.utils;

import com.azhon.appupdate.utils.ScreenUtil;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import ohos.agp.window.service.Display;
import ohos.agp.window.service.DisplayAttributes;
import ohos.agp.window.service.DisplayManager;
import ohos.app.Context;
import org.junit.Test;

import java.util.Optional;

import static org.junit.Assert.*;

public class ScreenUtilTest {

    private final Context mContext = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();

    @Test
    public void getWidth() {
        Optional<Display> display = DisplayManager.getInstance().getDefaultDisplay(mContext);
        DisplayAttributes dm = display.get().getAttributes();
        assertEquals(dm.width, ScreenUtil.getWidth(mContext));
    }

    @Test
    public void getHeight() {
        Optional<Display> display = DisplayManager.getInstance().getDefaultDisplay(mContext);
        DisplayAttributes dm = display.get().getAttributes();
        assertEquals(dm.height, ScreenUtil.getHeight(mContext));
    }
}